﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using PeopleFinderBusiness;
using System.Web.Security;

namespace PeopleFinder.Account
{
	public partial class Login : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
		}

		protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e)
		{
			UserController controller = new UserController();
			bool loggedIn = controller.Login(HttpContext.Current.Request.UserHostAddress, LoginUser.UserName, LoginUser.Password);
			if (!loggedIn)
			{
				e.Authenticated = false;
			}
			else
			{
				e.Authenticated = true;
			}
		}
	}
}
